
#include	"mpi.h"
#include	<stdio.h>
#include	<stdlib.h>


int
main ( int argc, char *argv[] )
{
	int myrank, nprocs;
	int mynumber, receivednumber;
	int src, dst;
	int tag = 111;
	MPI_Status status;

	MPI_Init( &argc, &argv );
	MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
	MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
	mynumber = myrank;
	dst = 1 - myrank; 
	src = myrank;
	if( myrank == 0 )
	{
		MPI_Send( &mynumber, 1, MPI_INT, dst, tag, MPI_COMM_WORLD );
		MPI_Recv( &receivednumber, 1, MPI_INT, dst, tag, MPI_COMM_WORLD, &status );	
	}
	else
	{
		MPI_Recv( &receivednumber, 1, MPI_INT, dst, tag, MPI_COMM_WORLD, &status );	
		MPI_Send( &mynumber, 1, MPI_INT, dst, tag, MPI_COMM_WORLD );
	}


	printf("Proc: %d Got %d\n", myrank, receivednumber );
	MPI_Finalize();
	return EXIT_SUCCESS;
}				/* ----------  end of function main  ---------- */
